﻿using SqlSugar;
using UserModels;

namespace UserRepositorys
{
    /// <summary>
    /// 上下文类
    /// </summary>
    public class UserDbcontext
    {
        public readonly ISqlSugarClient db;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="DBContext"></param>
        public UserDbcontext(ISqlSugarClient DBContext)
        {
            this.db = DBContext;
        }
        public void CreateTable()
        {
            db.DbMaintenance.CreateDatabase();//没有数据库则新建
            db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
            {
                 typeof(MenuInfoModel),//菜单信息表
                 typeof(RoleInfoModel),//角色表				
                 typeof(TiesInfoModel),//角色、菜单关系表				
                 typeof(UserInfoModel),//用户表				
                 typeof(DeptInfoModel),//部门表				
                 typeof(AccountInfoModel),//账号表				
                 typeof(AccountRoleModel),//用户角色关系表				
            });
        }
    }
}